package files;

import java.io.File;
import java.io.IOException;
import java.lang.Character.UnicodeBlock;
import java.nio.file.FileVisitor;
import java.nio.file.Path;

public class KanaBreaker {

	static String intToString(int num, int digits) {
	    StringBuffer s = new StringBuffer(digits);
	    int zeroes = digits - (int) (Math.log(num) / Math.log(10)) - 1; 
	    for (int i = 0; i < zeroes; i++) {
	        s.append(0);
	    }
	    return s.append(num).toString();
	}
	
	public static void main(String[] args) {
		String root1 = "K:\\(｡･｀ω´･｡)\\2d\\kemo";
		
		String name = "";
		String rename = "";
		boolean renamed = false;
		int length = 0;
		
		try {
			FileVisitor<Path> fileProcessor = new ProcessFile(root1, false);

			for(File f : ((ProcessFile) fileProcessor).getList()) {
				//System.out.println(f.getName());
				name = f.getName();
				rename = name;
				length = name.length();
				for (int i = 0; i < length; i++) {
				    char c = name.charAt(i);
				    if(Character.UnicodeBlock.of(c) != UnicodeBlock.BASIC_LATIN) {
				    	rename = rename.replace(c+"", "");
					    renamed = true;
				    }
				}
				if(renamed) {
					rename = rename.replaceFirst("\\s", "");
					System.out.println(name+"\t>\t"+rename);
					//f.renameTo(new File(f.getParentFile().getAbsolutePath()+"\\"+rename));
					//f.delete();
				}
				renamed = false;
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
